﻿using System;
using System.Collections.Generic;
using System.Text;

namespace lp_ge_gt
{
    class Gekosale
    {
        private string kod = "ean";
        public Boolean setStock(String[][] stock)
        {
            if (stock.Length == 0) return false;
            dbConn sh = new dbConn(dbConn.connType.shop);
            
            for (int i = 0; i < stock.Length; i++)
            {
                sh.query("UPDATE product SET stock = '" + stock[i][1].Replace(',', '.') + "' WHERE " + this.kod + "='" + stock[i][0] + "'", false);
            }
            //stock[]{0=>symbol,1=>stan}
            return false;
        }
        public Boolean setPrices(String[][] prices)
        {
            if (prices.Length == 0) return false;
            dbConn sh = new dbConn(dbConn.connType.shop);
            //prices[]{0=>symbol,1=>cenaZakupu,2=>cenaSprzedazy,3=>cenaPromocyjna}
            String que = "",separator ="";
            for (int i = 0; i < prices.Length; i++)
            {
                separator = "";
                que = "UPDATE product SET ";
                if (prices[i][1] != "null")
                {
                    que += separator + " buyprice = '" + prices[i][1].Replace(',', '.') + "'";
                    separator = ",";
                }
                if (prices[i][2] != "null")
                {
                    que +=separator + " sellprice = '" + prices[i][2].Replace(',', '.') + "'";
                    separator = ",";
                }
                if (prices[i][3] != "null")
                {
                    que += separator + " discountprice = '" + prices[i][3].Replace(',', '.') + "'";
                    separator = ",";
                }
                que += " WHERE " + this.kod + " = '" + prices[i][0] + "'";
                sh.query(que, false);
            }
            return false;
        }
    }
}
